<template>
	<view class="me-cell">
		<s-pull-scroll ref="pullScroll" :enablePullUp="false" :pullDown="pullDown" :pullUp="loadData" :back-top="true">
			<u-cell-group :border="false">
				<u-cell-item :border-bottom="false" :title="item.title" v-for="(item,index) in dataList" :key="index" @tap="userClickItem(item)"></u-cell-item>
			</u-cell-group>
		</s-pull-scroll>
		
		<mix-loading v-if="isLoading"></mix-loading>
	</view>
</template>

<script>
export default {
	data() {
		return {
			dataList: []
		};
	},
	onLoad() {
		this.refresh();
	},
	methods: {
		pullDown(pullScroll) {
			setTimeout(() => {
				this.loadData(pullScroll);
			}, 200);
		},
		userClickItem(item){
			getApp().globalData.helpItem=item;
			this.navTo(`/pages/public/helpdetails`);
		},
		async loadData(pullScroll) {
			const data = {
				pageNo: pullScroll.page,
				pageSize: "10"
			};
			const res = await this.$request("content/help-list", {}, {showLoading: true});
			if (pullScroll.page == 1) {
				this.dataList = [];
			}
			if (res.result == 1 || res.data.list.length == 0) {
				pullScroll.empty();
				return;
			}
			this.dataList = this.dataList.concat(res.data.list);
			pullScroll.page >= Math.ceil(res.data.count / 10) ? pullScroll.finish() : pullScroll.success();
		}
	}
};
</script>

<style></style>
